package com.lenovo.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Descpription Jenkins 拦截器
 * @Author CJF
 * @Date 2019/1/17 10:47
 **/

@Component
public class JenkinsBuildInterceptor implements HandlerInterceptor {

    /**
     * Jenkins JOB构建的权限码值为 32
     */
    private final Integer JENKINS_BUILD_LEVEL_NUM = 32;

    @Autowired
    private IfPermission ifPermission;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        return ifPermission.CheckPermission(JENKINS_BUILD_LEVEL_NUM, request, response);
    }
}
